<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'tanai-product-master-form',
	'enableAjaxValidation'=>false,
)); ?>
    
<?php 
        $quoteDollar = Config::model()->findByAttributes(array('tag'=>'dollar_quote'));
        $quoteThaiBaht = Config::model()->findByAttributes(array('tag'=>'thai_baht_quote_to_usd'));
        $valuePriceARS = round($model->price_thb * $quoteDollar->value * $quoteThaiBaht->value,2);
        $valuePriceUSD = round($model->price_thb * $quoteThaiBaht->value,2);
?>

	<p class="note">Los campos con <span class="required">*</span> son obligatorios.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'ref'); ?>
		<?php echo $form->textField($model,'ref',array('size'=>60,'maxlength'=>150)); ?>
		<?php echo $form->error($model,'ref'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'collection'); ?>
                <?php echo $form->dropDownList($model, 'collection', CHtml::listData(Category::model()->findAll(), 'tag', 'name'),array('empty' => 'Seleccione una categoría'),array('disabled'=>'disabled')); ?>
		<?php echo $form->error($model,'collection'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'collection_sub'); ?>
                <?php echo $form->dropDownList($model, 'collection_sub', CHtml::listData(Subcategory::model()->findAll(), 'tag', 'name'),array('empty' => 'Seleccione una subcategoría'),array('disabled'=>'disabled')); ?>
		<?php echo $form->error($model,'collection_sub'); ?>
	</div>
        
        <div class="row">
		<?php echo $form->labelEx($model,'price_thb'); ?>
		<?php echo $form->textField($model,'price_thb'); ?>
		<?php echo $form->error($model,'price_thb'); ?>
                <br />Costo (ARS): <?php echo CHtml::encode($valuePriceARS)?>
                <br />Costo (USD): <?php echo CHtml::encode($valuePriceUSD)?>
	</div>
        
        <div class="row">
                <?php $modelPrice = PriceProduct::model()->findByAttributes(array('id_ref'=>$model->ref));//TODO buscar por id de mejor forma VER!
                echo '<label for="wholesale_price">Precio particular Mayorista:</label>'; ?> 
                <?php echo CHtml::textField('wholesale_price',$modelPrice->wholesale_price);?>
        </div>

        <div class="row">
                <?php echo '<label for="retail_price">Precio particular Minorista:</label>'; ?>
                <?php echo CHtml::textField('retail_price',$modelPrice->retail_price) ;?>
        </div>
        
	<div class="row">
		<?php echo $form->labelEx($model,'grams'); ?>
		<?php echo $form->textField($model,'grams'); ?>
		<?php echo $form->error($model,'grams'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'p_size'); ?>
		<?php echo $form->textField($model,'p_size',array('size'=>60,'maxlength'=>180)); ?>
		<?php echo $form->error($model,'p_size'); ?>
	</div>
        
        <div class="row">
		<?php echo $form->labelEx($model,'length'); ?>
		<?php echo $form->textField($model,'length',array('size'=>60,'maxlength'=>180)); ?>
		<?php echo $form->error($model,'length'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'color'); ?>
		<?php echo $form->textField($model,'color',array('size'=>60,'maxlength'=>60)); ?>
		<?php echo $form->error($model,'color'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'stone'); ?>
		<?php echo $form->textField($model,'stone',array('size'=>60,'maxlength'=>150)); ?>
		<?php echo $form->error($model,'stone'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'comment'); ?>
		<?php echo $form->textField($model,'comment',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'comment'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Crear' : 'Guardar'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->